//
//  ZpStatusToolBar.m
//  WeiBo_OC
//
//  Created by MacBook Pro on 16/5/30.
//  Copyright © 2016年 MacBook Pro. All rights reserved.
//

#import "ZpStatusToolBar.h"

@interface ZpStatusToolBar ()
@property(nonatomic, strong) UIButton *reposts;
@property(nonatomic, strong) UIButton *comments;
@property(nonatomic, strong) UIButton *attitudes;
@property (nonatomic, strong) UIView *v1;
@property (nonatomic, strong) UIView *v2;
@end
@implementation ZpStatusToolBar

- (void)setStatus:(ZpStatus *)status{
    _status = status;
    [self addSubview:self.reposts];
    [self addSubview:self.comments];
    [self addSubview:self.attitudes];
    [self setUIConstraint];
}

- (void)setUIConstraint{
    
    [self.reposts makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self);
        make.width.equalTo(self.comments);
    }];
    
    [self.comments makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.reposts.right);
        make.width.equalTo(self.reposts);
    }];
    
    [self.attitudes makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self);
        make.left.equalTo(self.comments.right);
        make.width.equalTo(self.comments);
    }];
    

    [self.v1 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.reposts.right);
        make.centerY.equalTo(self.reposts);
        make.height.equalTo(self.reposts.height).multipliedBy(0.6);
        make.width.equalTo(1 / self.getScale);
    }];
    
    [self.v2 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.comments.right);
        make.centerY.equalTo(self);
        make.height.equalTo(self.reposts.height).multipliedBy(0.6);
        make.width.equalTo(1 / self.getScale);
    }];

}


- (UIButton *)reposts{
    if (!_reposts) {
        _reposts = [[UIButton alloc] init];
        [_reposts setImage:[UIImage imageNamed:@"timeline_icon_retweet"] forState:UIControlStateNormal];
        [_reposts setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        [_reposts setTitle:[NSString stringWithFormat:@"%ld", self.status.reposts_count] forState:UIControlStateNormal];
        _reposts.titleLabel.font = [UIFont systemFontOfSize:10];
        
    }
    return _reposts;
}

- (UIButton *)comments{
    if (!_comments) {
        _comments = [[UIButton alloc] init];
        [_comments setImage:[UIImage imageNamed:@"timeline_icon_comment"] forState:UIControlStateNormal];
        [_comments setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        [_comments setTitle:[NSString stringWithFormat:@"%ld", self.status.comments_count] forState:UIControlStateNormal];
        _comments.titleLabel.font = [UIFont systemFontOfSize:10];
        
        
    }
    return _comments;
}

- (UIButton *)attitudes{
    if (!_attitudes) {
        _attitudes = [[UIButton alloc] init];
        [_attitudes setImage:[UIImage imageNamed:@"timeline_icon_like"] forState:UIControlStateNormal];
        [_attitudes setImage:[UIImage imageNamed:@"timeline_icon_likeee"] forState:UIControlStateSelected];
        [_attitudes setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        [_attitudes setTitle:[NSString stringWithFormat:@"%ld", self.status.attitudes_count] forState:UIControlStateNormal];
        _attitudes.titleLabel.font = [UIFont systemFontOfSize:10];
        
    }
    return _attitudes;
}

- (UIView *)v1{
    if (!_v1) {
        _v1 = [[UIView alloc] init];
        _v1.backgroundColor = [UIColor blackColor];
        [self addSubview:_v1];
    }
    return _v1;
}

- (UIView *)v2{
    if (!_v2) {
        _v2 = [[UIView alloc] init];
        _v2.backgroundColor = [UIColor blackColor];
        
        [self addSubview:_v2];
    }
    return _v2;
}
@end
